package com.xy.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author 谢阳
 * @version 1.8.0_131
 * @date 2022/4/10 19:18
 * @description
 */

@WebServlet("/hello")
public class HelloServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //super.doGet(req, resp);
        Thread thread = Thread.currentThread();
        System.out.println(thread + "start...");
        try {
            sayHello();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        resp.getWriter().write("hello...");
        System.out.println(thread + "end...");
    }


    public void sayHello() throws InterruptedException {
        System.out.println(Thread.currentThread() + "processing...");

        Thread.sleep(3000);
    }
}
